package com.wk.job.heartbeat.master;

import java.util.concurrent.ConcurrentHashMap;

import com.wk.job.Job;
import com.wk.job.Task;
import com.wk.job.heartbeat.JobStateHeartbeat;
import com.wk.job.heartbeat.JobStateHeartbeatTransferer;
import com.wk.net.heartbeat.handler.HeartbeatHandler;
import com.wk.net.heartbeat.handler.HeartbeatReceiver;


public class JobStateHeartbeatHandler extends HeartbeatHandler<JobStateHeartbeat> {
	/**
	 * 处理Slave节点发送的心跳消息，汇报Job状态及Slave节点状态
	 * 
	 * @param receiver
	 *            接收心跳消息的底层实现
	 * @param jobs
	 *            收集参数：收集Job状态填入该集合
	 * @param checkPeriod
	 *            检查心跳的周期（单位：秒）
	 * @param absenceTolerance
	 *            掉线容忍度
	 */
	public JobStateHeartbeatHandler(HeartbeatReceiver receiver, ConcurrentHashMap<String, Job> jobs,ConcurrentHashMap<Integer,Task> tasks, int checkPeriod,
			int absenceTolerance) {
		super(new JobStateHeartbeatTransferer(), receiver, checkPeriod, absenceTolerance);
		
		setHeartbeatListener(new JobStateListener(jobs, tasks));
		setAbsenceListener(new AbsentSlaveListener());
	}
}
